home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / leda / incl / dwindow.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  6.3 KB  |  248 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  dwindow.h
  7. +
  8. +
  9. +  Copyright (c) 1991  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef DWINDOWH
  16. #define DWINDOWH
  17.  
  18. #include<LEDA/plane.h>
  19.  
  20. // #include<stdio.h>
  21. // #include<conio.h>
  22. // #include<iostream.h>
  23. // #include<stdlib.h>
  24. // #include<math.h>
  25. // #include<ctype.h>
  26.  
  27. typedef double (*draw_func_ptr) (double);
  28. typedef void   (*redraw_func_ptr) ();
  29. typedef void   (*mouse_action_func_ptr) (double,double);
  30.  
  31.  
  32. enum color
  33. {   black,
  34.     blue,
  35.     green,
  36.     cyan,
  37.     red,
  38.     magenta,
  39.     brown,
  40.     lightgray,
  41.     darkgray,
  42.     lightblue,
  43.     lightgreen,
  44.     lightcyan,
  45.     lightred,
  46.     lightmagenta,
  47.     yellow,
  48.     white
  49. };
  50.  
  51. enum line_style    { solid=0, dotted=1, center=2, dashed=3 };
  52. enum drawing_mode  { src_mode=0, xor_mode=1 };
  53. enum line_width    { norm=1, thick=3 };
  54. enum mouse_button  { none=0, Left=1, Middle=4, Right=2 };
  55.  
  56. // enum text_mode ist hier nicht moeglich
  57.  
  58.  
  59.  
  60. class dwindow
  61. {  // hier kommen je nach Graphikpaket (z.B.) Variablen
  62.  
  63.    int nw;
  64.    line_style ls;
  65.    line_width lw;
  66.    drawing_mode dm;
  67.    int mes;
  68.  
  69.    public:
  70.  
  71.    // constructor (initialization)
  72.  
  73.    dwindow()
  74.    {  nw=10;
  75.       ls=solid;
  76.       lw=norm;
  77.       dm=src_mode;
  78.       mes=0;
  79.       init();
  80.    }
  81.  
  82.  
  83.    // destructor
  84.  
  85.    ~dwindow();
  86.  
  87.    void init();              // Die Funktionen werden genauso benannt
  88.    void clear();             // wie im LEDA Manual.
  89.  
  90.    // ***** setting parameters
  91.  
  92.    line_style   set_line_style(line_style s);
  93.    line_width   set_line_width(line_width w);   // nur norm und thick moeglich
  94.    int          set_node_width(int w);
  95.    drawing_mode set_mode(drawing_mode m);
  96.  
  97.  
  98.    // ***** getting parameters
  99.  
  100.    line_width   get_line_width();
  101.    int          get_node_width();
  102.    line_style   get_line_style();
  103.    drawing_mode get_mode();
  104.  
  105.    double xmin();  // nur der Vollstaendigkeit halber, liefert
  106.    double xmax();  // je nach Aufloesung die Eckkoordinaten des
  107.    double ymin();  // Grafikschirms
  108.    double ymax();
  109.  
  110.  
  111.    // ***** drawing segments
  112.  
  113.    void draw_segment(double, double, double, double, color c=white);
  114.    // void draw_segment(point, point, color c=white);
  115.    // void draw_segment(segment, color c=white);
  116.  
  117.  
  118.    // ***** drawing lines
  119.  
  120.    void draw_line(double, double, double, double, color c=white);
  121.    // void draw_line(point p, point q, color c=black);
  122.    // void draw_line(line l, color c=black);
  123.    void draw_hline(double, color c=white);
  124.    void draw_vline(double, color c=white);
  125.  
  126.  
  127.    // ***** drawing arrows
  128.  
  129.    void draw_arrow(double, double, double, double, color c=white);
  130.    // void draw_arrow(point p, point q, color c=black);
  131.    // void draw_arrow(segment s, color c=black);
  132.  
  133.  
  134.    // ***** drawing edges
  135.  
  136.    void draw_edge(double, double, double, double, color c=white);
  137.    // void draw_edge(point p, point q, color c=black);
  138.    // void draw_edge(segment s, color c=black);
  139.  
  140.    void draw_edge_arrow(double, double, double, double, color c=white);
  141.    // void draw_edge_arrow(point p, point q, color c=black);
  142.    // void draw_edge_arrow(segment s, color c=black);
  143.  
  144.  
  145.    // ***** drawing points
  146.  
  147.    void draw_point(double x0, double y0, color c=white);
  148.    // void draw_point(point p, color c=BLACK);
  149.  
  150.    // ***** drawing nodes
  151.  
  152.    void draw_node(double x0, double y0, color c=white);
  153.    // void draw_node(point p, color c=white);
  154.    void draw_filled_node(double x0, double y0, color c=white);
  155.    // void draw_filled_nodepoint p, color c=white);
  156.    void draw_text_node(double x0, double y0, char *s, color c=white);
  157.    // void draw_text_node(point p, char *s, color c=white);
  158.    void draw_int_node(double x0, double y0, int i, color c=white);
  159.    // void draw_int_node(point p, int i, color c=white);
  160.  
  161.  
  162.    // ***** drawing circles
  163.  
  164.    void draw_circle(double x, double y, double r, color c=white);
  165.    // void draw_circle(point p, double r, color c=white);
  166.    // void draw_circle(circle c, double r, color c=white);
  167.  
  168.    void draw_disc(double x, double y, double r, color c=white);
  169.    // void draw_disc(point p, double r, color c=white);
  170.    // void draw_disc(circle c, double r, color c=white);
  171.  
  172.  
  173.    // ***** drawing polygons
  174.  
  175.    // void draw_polygon(list(point) lp, color c=white);
  176.    // void draw_polygon(polygon P, color c=white);
  177.    // void draw_filled_polygon(list(point) lp, color c=white);
  178.    // void draw_filled_polygon(polygon P, color c=white);
  179.  
  180.  
  181.    // ***** text
  182.  
  183.    void draw_text(double x, double y, char *s, color c=white);
  184.    // void draw_text(point p, char *s, color c=white);
  185.    void draw_ctext(double x, double y, char *s, color c=white);
  186.    // void draw_ctext(point p, char *s, color c=white);
  187.  
  188.  
  189.    // ***** drawing functions
  190.  
  191.    void plot_xy(double x0, double x1, draw_func_ptr f, color c=white);
  192.    void plot_yx(double y0, double y1, draw_func_ptr f, color c=white);
  193.  
  194.  
  195.    // ***** miscellaneous
  196.  
  197.    void copy_rect(double, double, double, double, double, double);
  198.    void message(char*);  // spaeter string
  199.    void del_message();
  200.  
  201.    // ***** mouse input
  202.  
  203.    int read_mouse();
  204.    int read_mouse(double&, double&);
  205.    int read_mouse_seg(double, double, double&, double&);
  206.    // int read_mouse(real&, real&);
  207.    // int read_mouse_seg(double, double, real&, real&);
  208.    int read_mouse_rect(double, double, double&, double&);
  209.    int read_mouse_circle(double, double, double&, double&);
  210.    // int read_mouse_rect(double, double, real&, real&);
  211.    // int read_mouse_circle(double, double, real&, real&);
  212.    int read_mouse_action(mouse_action_func_ptr, double&, double&);
  213.    // int read_mouse_action(mouse_action_func_ptr, real&, real&);
  214.  
  215.    int confirm(char *s);
  216.    int acknowledge(char *s);
  217.  
  218.    char*    read_string(char*);
  219.    double   read_real(char*);
  220.    long int read_int(char*);
  221.  
  222.  
  223.    //  ***** overloaded read and draw functions
  224.  
  225.    //  kommt alles spaeter
  226.  
  227.    // ***** input operators
  228.  
  229.    // dwindow& operator>>(point&);
  230.    // dwindow& operator>>(segment&);
  231.    // dwindow& operator>>(line&);
  232.    // dwindow& operator>>(circle&);
  233.    // dwindow& operator>>(polygon&);
  234.  
  235.    // ***** output operators
  236.  
  237.    // dwindow& operator<<(point&);
  238.    // dwindow& operator<<(segment&);
  239.    // dwindow& operator<<(line&);
  240.    // dwindow& operator<<(circle&);
  241.    // dwindow& operator<<(polygon&);
  242.  
  243.  
  244. };  // end of class dwindow
  245.  
  246. #endif
  247.